package org.example.Controller;

import org.example.domain.Food;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/foods")
public class FoodController {
    @PostMapping
    public String save(@RequestBody Food food) {
        System.out.println("save" + food);
        return "保存成功";

    }

    @GetMapping
    public List<Food> getAll() {
        System.out.println("查询成功");
        List<Food> foodList = new ArrayList<Food>();
        Food list1 = new Food();
        list1.setName("小炒肉");
        list1.setType("牛");
        list1.setDescription("小炒牛");
        foodList.add(list1);
        Food list2 = new Food();
        list2.setName("炖菜");
        list2.setType("菜");
        list2.setDescription("炖菜");
        foodList.add(list2);

        Food list3 = new Food();
        list3.setName("奶茶");
        list3.setType("饮品");
        list3.setDescription("瑞星");
        foodList.add(list3);
        return foodList;


    }


}
